<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <div id="app">
    <ul>
      <li v-for="cate in cates" :key="cate.id">
        <h5>{{cate.name}}</h5>
        <img :src="cate.icon" alt="">
      </li>
    </ul>
  </div>
  <script src="./vue.js"></script>
  <script src="./axios.js"></script>
  <script>

    axios.defaults.baseURL = 'https://api.it120.cc/conner';
   
    // 拦截器
    axios.interceptors.request.use(function (config) {
      console.log('拦截器触发了，请求配置是', config);
      config.headers.token = '654321';
      return config;
    }, function (error) {

      return Promise.reject(error);
    });


    axios.interceptors.response.use(function (res) {
      console.log('响应拦截器触发了', res);
     
      return res;
    }, function (error) {

      return Promise.reject(error);
    });
    const vm = new Vue({
      el: '#app',
      data: {
        cates: [],
        arts: []
      },
      methods: {
        fetchArts() {
          axios.post('/cms/news/list/v2', "page=1&pageSize=10").then(res => {
            console.log(res);
          })
        },
        fetchCates() {
          // /cms/category/list  /cms/news/list/v2
          axios({
            url: '/cms/category/list',
            method: 'get',
            params: {
              a: 10,
              b: 20
            }
          }).then(res => {
            console.log(res);
          })
        }
      },
      created() {
        this.fetchCates();
        this.fetchArts();
      }
    })
  </script>
</body>

</html>